package cn.south.campus.business.model.enums;

import cn.south.campus.business.model.entity.Config;
import com.alibaba.fastjson2.JSON;

/**
 * <p>
 *
 * </p>
 *
 * @author chow
 * @since 2025/1/9 8:36
 */
public enum ConfigTypeEnums {
    OBJECT(0, "对象"),
    ARRAY(1, "数组"),
    STRING(2, "字符串"),
    ;

    public static Object parseValGet(Config config) {
        Integer configType = config.getConfigType();
        switch (configType) {
            case 0:
                return JSON.parseObject(config.getConfigValue());
            case 1:
                return JSON.parseArray(config.getConfigValue());
            case 2:
                return config.getConfigValue();
            default:
                return null;
        }
    }

    private final Integer code;
    private final String desc;

    ConfigTypeEnums(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
